
import { createRouter, createWebHistory } from 'vue-router'

//引入组件用于路由
import loginView from '../views/login/login.vue'
import LayoutView from '@/views/layout/index.vue'
//引入用户管理组件
import UserView from '@/views/user/index.vue'
import HomeView from '@/views/index/index.vue'


const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes: [
    {path: '/login',name: 'login',component: loginView},
    // 主布局路由
    {
      path: '/',
      name:'',
      component: LayoutView,
      redirect: '/index', //默认子路由
      // 二级子路由
      children:[
        {path: '/index',name: 'index',component: HomeView},
        {path: '/user', name: 'user', component: UserView}
      ]
    },
  ]
})

export default router
